<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class StoreGoods extends Base
{
    use HasFactory;
    use SoftDeletes;

    protected $table = "store_goods";
    protected $guarded = [];



    /**
     * @param $id
     * @param $post
     * @return mixed
     * User: 张浩
     * Date: 2022/11/20
     * Time: 19:07
     * 拼团修改商品库存
     */
    public static function StoreGoodsRepertory($id, $post)
    {
        return self::where('id', $id)->update($post);
    }

    /**
     * @param $id
     * @return mixed
     * User: 张浩
     * Date: 2022/11/19
     * Time: 9:35
     * 根据商品id获取一条数据
     */
    public static function GoodsFirst($id)
    {
        return self::where('id', $id)->first()->toArray();
    }

    /**
     * @return mixed
     * User: 张浩
     * Date: 2022/11/16
     * Time: 14:38
     * 拼团列表数据获取
     */
    public static function wxGroupBookingList()
    {
        return self::where('is_groupbooking', 1)->paginate(5)->toArray();
    }

    /**
     * @return mixed
     * User: 张浩
     * Date: 2022/11/24
     * Time: 8:27
     * 获取所有拼团数据
     */
    public static function GroupBookingShow()
    {
        return self::where('is_groupbooking', 1)->get()->toArray();
    }
}
